package com.linkage.educloud.ah.adapter.topic;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.linkage.educloud.ah.R;

/**
 * Created by Mr'Tang on 2018/12/4.
 */

public class TopicDetailLabelAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private String[] labels;
    private Context mcontext;

    public TopicDetailLabelAdapter(Context context, String[] datas) {
        this.mcontext = context;
        this.labels = datas;
    }

    @Override
    public int getCount() {
        return labels.length;
    }

    @Override
    public String getItem(int arg0) {
        return labels[arg0];
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(final int arg0, View view, ViewGroup arg2) {
        final ViewHolder holder;
        if (view == null) {
            inflater = LayoutInflater.from(mcontext);
            view = inflater.inflate(R.layout.item_topic_detail_label, null);
            holder = new ViewHolder();
            holder.item_topic_detail_label_name = view.findViewById(R.id.item_topic_detail_label_name);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.item_topic_detail_label_name.setText(labels[arg0]);
        return view;
    }

    public class ViewHolder {
        private TextView item_topic_detail_label_name;
    }
}

